package com.eyewind.myapplication

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.ew.sdk.SDKAgent
import com.eyewind.nativead.NativeAdWrapAdapter
import com.tjbaobao.framework.base.BaseRecyclerAdapter
import com.tjbaobao.framework.ui.BaseRecyclerView
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    private val list : MutableList<String> = ArrayList()
    private val adapter : Adapter = Adapter(list,R.layout.app_ad_layout)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        SDKAgent.onCreate(this)

        for (i : Int in 0..10)
        {
            list.add("$i")
        }
        val nativeAdWrapAdapter = NativeAdWrapAdapter.Builder(
                this, adapter,  R.layout.app_ad_layout)
                .nonSquareImage() // 可选，广告为非方形图
                .topBanner()   // 可选，广告为top banner广告
                .create()

        viewPagerRecyclerView.adapter = nativeAdWrapAdapter
    }

    inner class Holder(itemView: View?) : BaseRecyclerView.BaseViewHolder(itemView)
    {
        override fun onInitView(itemView: View?) {

        }
    }

    inner class Adapter(list : List<String>,layoutId : Int) : BaseRecyclerAdapter<Holder, String>(list,layoutId)
    {
        override fun onGetHolder(view: View?): Holder {
            return Holder(view)
        }

        override fun onBindViewHolder(holder: Holder, info: String, position: Int) {
        }


    }

    override fun onPause() {
        super.onPause()
        SDKAgent.onPause(this)
    }

    override fun onResume() {
        super.onResume()
        SDKAgent.onResume(this)
    }

    override fun onDestroy() {
        super.onDestroy()
        SDKAgent.onDestroy(this)
    }
}
